package com.josework.springhelloworld.model;

import lombok.Builder;
import lombok.Data;

import java.util.Objects;

@Data
@Builder
public class Person implements Comparable{
    private String name;

    private Long id_card;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id_card, person.id_card);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, id_card);
    }


    @Override
    public int compareTo(Object o) {
        Person p = (Person) o;
        int result = id_card > p.id_card ? 1 : (id_card == p.id_card? 0 : -1);
        return result;
    }



}
